<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>1.ES6_class</title>
</head>
<body>
<script type="text/javascript">
  class  Animal{
      constructor(month,category) {
          this.month =month;
          this.category =category;
      }

      getMonth(){
          return this.month;
      }
  }

  class Dog extends Animal{
      /*子类如果使用构造方法，那么在构造方法的首行就要使用super调用父类的构造方法*/
      constructor(month,category,dogName) {
          /*子类继承父类子类会拥有父类的全部属性,要为继承过来的属性赋值所以要使用父类的构造方法*/
          super(month,category);
          /*子类自己新添加的属性要手动赋值*/
          this.dogName = dogName;
          /*也就是说子类的构造函数不仅要为从父类继承来的属性赋值
          * 也要为自己自定义的属性赋值*/
      }

  }

    let dog =new Dog("12","柯基");
    console.log(dog.getMonth());
    let animal =new Animal();
    console.log(animal.getMonth());

    console.log(dog);
    console.log(animal);

</script>
</body>
</html>